<?php
       
    include "database.php";
    
    //Za delovanje seje na vseh nivojih
    session_set_cookie_params(0,"/");
    session_start();
    if(!isset($_SESSION['username'])) {
        header("Location: login.php");
    } 
    $user_id = $_SESSION['id'];
    
?>  
<!DOCTYPE html>

<html>
	<head>
	    <meta charset="utf-8">
		
		<!-- Font weight: light (300) & semibold (600) -->
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:600,300' rel='stylesheet' type='text/css'>
		<link rel="stylesheet" href="css/default.css"/>
		<link rel="stylesheet" href="css/tabs.css"/>
		<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
		
		<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.10.2.custom.min.js"></script> 
		<script type="text/javascript" src="js/actions.js"></script>
		
		<title>Scrum | Progress Report</title>		
	</head>
	
	<body>
	
		<span id="username"><?php echo $_SESSION['username']  ?></span>
		<span id="separator">|</span>
		<span id="role"><a href="edit_profile.php">edit</a></span>
		
		<h1>Scrum</h1>
		
		<menu>
			<li><a href="control_panel.php">control<span>Panel</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="project_wall.php">project<span>Wall</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="product_backlog.php">product<span>Backlog</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="sprint_backlog.php">sprint<span>Backlog</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="my_tasks.php">my<span>Tasks</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a class="active" href="progress_report.php">progress<span>Reports</span></a>&nbsp;&nbsp;|&nbsp;</li>
			<li><a href="login.php">logout</a></li>
		</menu>
		
		<section>
		
			<div id="all_stories" class="stories_container">
				<div class="story">
					<input type="hidden" name="story_id" value="1" />
					
					<div class="header">
						<h4>Burn down chart</h4>
					</div>
                                        <?php 
                                           //include "database.php";
                                            $query = "SELECT current_project FROM user WHERE id='$user_id'";
                                            $project_id = mysql_fetch_array(executeQuery($query))[0];
                                            $query = "SELECT count(hours_remaining) FROM task t, task_work tw, story s WHERE t.task_id=tw.task_id AND s.story_id=t.story_id AND project_id = '$project_id'";
                                            $result = executeQuery($query);
                                            if(mysql_num_rows($result)==0 || $res = mysql_fetch_array($result)[0]==0){
                                                echo "<h5>No work done on this project.</h5> <br />";
                                        ?>
                                            
					<?php } else {
                                            echo "<p align='center'><img src='./pChart2.1.3/graf.php'/></p>";
                                        }
                                            
                                            ?>
					<br />
					
					<p>X-axis: days since project start</p>
					<p>Y-axis: hours of work</p>
				</div>
		
		</section>
		
	</body>
</html>